

#include <cstring>
#include <string>
#include <cstdio>
#include <iostream>
using namespace std;
int cnt = 1;
class A
{
public:
    A()
    {
        t = cnt++;
        cout<<"Constuct A() id="<<t<<endl;
    }
    A(const A& a)
    {
        cout<<"Copy Construct A() right="<<a.t<<" new->"<<cnt<<endl;
        t = cnt++;
    }
    ~A()
    {
        cout<<"~A() id="<<t<<endl;
    }
    A& operator = (const A& a)
    {
        cout<<"= operation left="<<t<<" right="<<a.t<<" new->"<<cnt<<endl;
        t = cnt++;
        return *this;
    }
    void Print()
    {
        cout<<"Print id="<<t<<endl;
    }
private:
    int t;
};

A& f(A a)
{
    cout<<"In f()"<<endl;
    //a = A();
    cout<<"Out f()"<<endl;
    return a;
}

int main()
{
    A a;
    cout<<"Before f()"<<endl;
    A b = f(a);
    a = f(a);
    //a.Print();
    cout<<"After f()"<<endl;
    //a.Print();
   /*
    cout<<"Before f()"<<endl;
    A b = f(a);
    cout<<"After f()"<<endl;
    */
    return 0;
}
